﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eProject_SEM3_SecurityServices.Bussiness;
using eProject_SEM3_SecurityServices.ObjectClass;

namespace eProject_SEM3_SecurityServices
{
    public partial class WebForm7 : System.Web.UI.Page
    {
        BCustomer bc = null;
        BContractDetail bcd = null;
        BService bs = null;
        int ServiceID = 0;
        int contractId = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            bc = new BCustomer();
            bs = new BService();
            bcd = new BContractDetail();
            int num = Convert.ToInt32(Request.QueryString["contractId"]);
            contractId = num;
            ContractDetailOnContract(num);

            int customerID = Convert.ToInt32(Request.QueryString["CustomerID"]);
            CustomerDetailonContract(customerID);

            ServiceDetailOnContract(ServiceID);
        }

        public void CustomerDetailonContract(int cusID)
        {
            OCustomer oc = bc.GetCustomerDetails(cusID);
            lblCustomerID.Text = oc.CustomerID.ToString();
            lblCustomerName.Text = oc.CustomerName;
            lblCustomerPhone.Text = oc.CustomerPhone;
            lblCustomerAddress.Text = oc.CustomerAddress;
        }
        public void ContractDetailOnContract(int contractID)
        {
            OContractDetail ocd = bcd.getContractDetail(contractID);
            lblContractID.Text = ocd.ContractId.ToString();
            lblRegistryDate.Text = ocd.RegistryDay;
            lblStartDate.Text = ocd.StartDay;
            lblEndDate.Text = ocd.EndDay;
            lblNumberOfEmp.Text = ocd.NumberEmployee.ToString();
            ServiceID = ocd.ServiceId;
        }
        public void ServiceDetailOnContract(int ServiceID)
        {
            OService service = bs.getServiceDetails(ServiceID);
            lblserviceID.Text = service.ServiceId.ToString();
            lblserviceName.Text = service.ServiceName;
            lblserviceDescription.Text = service.ServiceDescription;
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            int number = int.Parse(lblNumberOfEmp.Text.Trim());
            Response.Redirect("frmEmployeeContract.aspx?serviceId=" + ServiceID + "&contractId="+contractId+"&numberEmployee="+number);
        }
    }
}